import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
import Layout from '@/layout'
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/login.vue'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: { title: '主页', icon: 'el-icon-s-home' }
    }]
  },
  {
    path: '/banner',
    component: Layout,
    name:"条幅管理",
    meta: {title: "条幅管理",icon: "el-icon-s-tools"},
    children: [
      {
        path: 'list',
        name: 'index',
        component: () => import('@/views/banner/index'),
        meta: { title: 'display', icon: 'el-icon-picture' }
      },
      {
        path: 'publish/:id',
        name: 'publish',
        component: () => import('@/views/banner/publish.vue'),
        meta: { title: 'publish', icon: 'el-icon-upload2' }
      }
    ]
  },

  {
    path: '/classify',
    component: Layout,
    name:"壁纸分类管理",
    meta: {title: "壁纸分类管理",icon: "el-icon-s-tools"},
    children: [
      {
        path: 'list',
        name: 'classify',
        component: () => import('@/views/classify/Index.vue'),
        meta: { title: 'display', icon: 'el-icon-picture' }
      },
      {
        path: 'publish/:id',
        name: 'publish',
        component: () => import('@/views/classify/publish.vue'),
        meta: { title: 'publish', icon: 'el-icon-upload2' }
      }
    ]
  },

  {
    path: '/wallpaper',
    component: Layout,
    name:"壁纸管理",
    meta: {title: "壁纸管理",icon: "el-icon-s-tools"},
    children: [
      {
        path: 'list',
        name: 'wallpaper',
        component: () => import('@/views/wallpaper/index.vue'),
        meta: { title: 'display', icon: 'el-icon-picture' }
      },
      {
        path: 'publish/:id',
        name: 'publish',
        component: () => import('@/views/wallpaper/publish.vue'),
        meta: { title: 'publish', icon: 'el-icon-upload2' }
      }
    ]
  },


  { path: '*', redirect: '/404', hidden: true }
]
const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
